package src.main.qiaojie;
/**桥接模式：定义形状与颜色进行桥接*/
public class TestDemo2 {

    public static void main(String[] args) {
        //拼接形状和颜色
        //矩形蓝色
        ShapeType rectangle=new Rectangle(10,8);
        ColoerType coloerType1=new Blue();
        System.out.println(rectangle.creationShape()+" "+coloerType1.creationColoer());
        //圆形红色
        ShapeType circular=new Circular(1,1,10);
        ColoerType coloerType2=new Red();
        System.out.println(circular.creationShape()+" "+coloerType2.creationColoer());
        //圆形蓝色
        ShapeType circular2=new Circular(5,6,10);
        ColoerType coloerType22=new Blue();
        System.out.println(circular2.creationShape()+" "+coloerType22.creationColoer());
    }
}


/**形状*/
interface ShapeType{
    String creationShape();
}
/**矩形*/
class Rectangle implements ShapeType{
    int l,h;
    String shape="矩形";
    public Rectangle(int l ,int h){
        this.l=l;
        this.h=h;
    }
    @Override
    public String creationShape() {
       return creationRectangle();
    }

    private String creationRectangle(){
       return this.shape+"：长l: "+ l +",宽h: " +h ;
    }
}

/**圆形*/
class Circular implements ShapeType{
    int x,y,radius;
    String shape="圆形";
    public Circular(int x,int y,int radius){
        this.x=x;
        this.y=y;
        this.radius=radius;
    }
    @Override
    public String creationShape() {
        return creationCircular();
    }

    private String creationCircular(){
        return this.shape+"：半径:"+ radius +",圆心(x:" +x+",y:"+ y +")";
    }
}



/**颜色*/
interface ColoerType{
    String creationColoer();
}

class Red implements ColoerType{
    private String coloer;
    public Red(){
        this.coloer="红色";
    }

    @Override
    public String creationColoer() {
        return "颜色："+this.coloer;
    }
}

class Blue implements ColoerType{
    private String coloer;
    public Blue(){
        this.coloer="蓝色";
    }

    @Override
    public String creationColoer() {
        return "颜色："+this.coloer;
    }
}